package ExamSystemClient.managerSystem.ExamManagement;

import ExamSystemClient.client.ClientScanner;
import ExamSystemClient.model.ChoiceQuestion;

import java.util.List;
import java.util.Scanner;

/**
 * 删除信息
 *
 * @author huangshuxian
 */
public class DeleteQuestion extends QuestionManage {

    public DeleteQuestion(List<ChoiceQuestion> questions) {
        super(questions);
    }

    @Override
    public void operate() {
        //1、提示用户输入删除的考题编号
        System.out.println("请输入要删除的考题编号：");
        int number = ClientScanner.getScanner().nextInt();
        //2、遍历列表找到需要删除的数据索引
        int index = getIndexByNumber(number);
        if (index >= 0){
            ChoiceQuestion removeInfo = questions.remove(index);
            System.out.println("删除的考题为：" + removeInfo);
        }else{
            System.out.println("没有找到匹配的考题，删除失败！");
        }
    }

    @Override
    public DeleteQuestion show() {
        System.out.println("删除学生信息！");
        return this;
    }
}
